package com.sys.SysSales.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sys.common.annotation.Log;
import com.sys.common.core.controller.BaseController;
import com.sys.common.core.domain.AjaxResult;
import com.sys.common.enums.BusinessType;
import com.sys.SysSales.domain.SysSalesOrders;
import com.sys.SysSales.service.ISysSalesOrdersService;
import com.sys.common.utils.poi.ExcelUtil;
import com.sys.common.core.page.TableDataInfo;

/**
 * 订单主表Controller
 * 
 * @author ruoyi
 * @date 2025-09-26
 */
@RestController
@RequestMapping("/SysSales/SysSalesOrders")
public class SysSalesOrdersController extends BaseController
{
    @Autowired
    private ISysSalesOrdersService sysSalesOrdersService;

    /**
     * 查询订单主表列表
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesOrders:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSalesOrders sysSalesOrders)
    {
        startPage();
        List<SysSalesOrders> list = sysSalesOrdersService.selectSysSalesOrdersList(sysSalesOrders);
        return getDataTable(list);
    }

    /**
     * 导出订单主表列表
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesOrders:export')")
    @Log(title = "订单主表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSalesOrders sysSalesOrders)
    {
        List<SysSalesOrders> list = sysSalesOrdersService.selectSysSalesOrdersList(sysSalesOrders);
        ExcelUtil<SysSalesOrders> util = new ExcelUtil<SysSalesOrders>(SysSalesOrders.class);
        util.exportExcel(response, list, "订单主表数据");
    }

    /**
     * 获取订单主表详细信息
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesOrders:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return success(sysSalesOrdersService.selectSysSalesOrdersByOrderId(orderId));
    }

    /**
     * 新增订单主表
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesOrders:add')")
    @Log(title = "订单主表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSalesOrders sysSalesOrders)
    {
        return toAjax(sysSalesOrdersService.insertSysSalesOrders(sysSalesOrders));
    }

    /**
     * 修改订单主表
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesOrders:edit')")
    @Log(title = "订单主表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSalesOrders sysSalesOrders)
    {
        return toAjax(sysSalesOrdersService.updateSysSalesOrders(sysSalesOrders));
    }

    /**
     * 删除订单主表
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesOrders:remove')")
    @Log(title = "订单主表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(sysSalesOrdersService.deleteSysSalesOrdersByOrderIds(orderIds));
    }
}
